#!/bin/bash

#这篇文档的作用是计算被链接次数（X）与平均refer次数的关系

merge_stat="/data/link_analyse/merge_stat.txt"

awk '
{
    if ($2 in sumStat) {
        sumStat[$2] += $3;
        numStat[$2] += 1;
    }
    else {
        sumStat[$2] = $3;
        numStat[$2] = 1;
    }
}
END {
    for (linkNum in sumStat) {
        printf("%d %d %d %.2f\n", linkNum, sumStat[linkNum], numStat[linkNum], sumStat[linkNum]*1.0/numStat[linkNum]);
    }
}' $merge_stat | sort -k1n > /data/link_analyse/linkNum_avgReferNum.txt
